import threading

import requests
url = 'https://api.web.360kan.com/v1/rank?cat=7'

import asyncio
import aiohttp
# response = requests.get(url, headers=headers)
# print(response.json())

#
# async def fetch(sessionid,url):
#     async with sessionid.get(url) as response:
#         return await response.json()
#
# async def main():
#     async with aiohttp.ClientSession() as session:
#         urls = [f'https://api.web.360kan.com/v1/rank?cat={i}'for i in range(1,7)]
#         tasks = [fetch(session,url) for url in urls]
#         result = await asyncio.gather(*tasks)
#         for data in result:
#             print(data)
#
# asyncio.run(main())

import requests
import threading

import requests
import threading

def fetch(url, yer):
    response = requests.get(url)
    yer.append(response.json())  # 把结果添加到列表中

def main():
    urls = [f'https://api.web.360kan.com/v1/rank?cat={i}' for i in range(1, 7)]
    yer = []
    threads = []

    for url in urls:
        thread = threading.Thread(target=fetch, args=(url, yer))
        thread.start()
        threads.append(thread)

    # 等待所有线程完成
    for thread in threads:
        thread.join()

    for data in yer:
        print(data)# 打印结果列表，而不是线程列表

main()


